﻿<UserControl x:Class="Hopscotch.Presentation.TradeModule.Views.TradeBlotterView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
			 xmlns:tradeVms="clr-namespace:Hopscotch.Presentation.TradeModule.ViewModels;assembly=Hopscotch.Presentation.TradeModule"			 
			 xmlns:cmnConsts="clr-namespace:Hopscotch.Presentation.Common.Constants;assembly=Hopscotch.Presentation.Common"
			 xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"  
			 
			 mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="700"			
			 d:DataContext="{d:DesignInstance Type=tradeVms:TradeBlotterViewModel, IsDesignTimeCreatable=True}">
    
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <ei:CallMethodAction TargetObject="{Binding}" MethodName="OnLoaded" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    
    <DockPanel LastChildFill="True">
		
		<!--Toolbar-->
		<ToolBarTray DockPanel.Dock="Top" IsLocked="False" AllowDrop="True">
			<ToolBar Band="1" BandIndex="1">
                <Image ToolTip="{Binding Path=ConnectionState}">
                    <Image.Style>
                        <Style TargetType="{x:Type Image}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsConnected}" Value="true">
                                    <Setter Property="Source" Value="pack://application:,,,/Hopscotch.Presentation.Common;component/Images/lighting16.png"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsConnected}" Value="false">
                                    <Setter Property="Source" Value="pack://application:,,,/Hopscotch.Presentation.Common;component/Images/disconnected16.png"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>
				<ribbon:RibbonMenuButton
					ToolTip="Interop Broadcasts"
					SmallImageSource="pack://application:,,,/Hopscotch.Presentation.Common;component/Images/broadcast16.png"			
					ItemsSource="{Binding InteropMenuItems}">				
					
				<!--Note: Ignore the binding error on this control-->
				<!--http://social.msdn.microsoft.com/Forums/vstudio/en-US/e697ac9e-fac3-4ede-9e2a-8fe15aad8791/ribbonmenubutton-gives-error-40-in-immediate-window?forum=wpf-->
				<ribbon:RibbonMenuButton.ItemContainerStyle >
						<Style TargetType="RibbonMenuItem" >
							<Setter Property="Header" Value="{Binding Key}"/>
							<Setter Property="IsCheckable" Value="True"/>
							<Setter Property="IsChecked" Value="{Binding Path=Value.IsChecked}"/>							
						</Style>
					</ribbon:RibbonMenuButton.ItemContainerStyle>
				</ribbon:RibbonMenuButton>
                <Button Command="{Binding RefreshQueryCommand}">
                    <Image Source="pack://application:,,,/Hopscotch.Presentation.Common;component/Images/refresh16.png" ToolTip="Refresh Query"/>
                </Button>
            </ToolBar>
		</ToolBarTray>

        <StatusBar DockPanel.Dock="Bottom" x:Name="statusBar" VerticalAlignment="Bottom">
            <StatusBarItem Content="Running.."/>
            <StatusBarItem></StatusBarItem>
        </StatusBar>
        
		<ListView x:Name="tradeListView" BorderThickness="0" Width="Auto" AlternationCount="2"
				  ItemsSource="{Binding Path=Trades}"
				  SelectedItem="{Binding Path=SelectedTrade, Delay={x:Static cmnConsts:InteropConstants.InteropBroadcastDelay}}">
			
			<ListView.Resources>
				<DataTemplate x:Key="chkBoxCell">
					<StackPanel Orientation="Horizontal">
						<CheckBox IsChecked="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}"/>
					</StackPanel>
				</DataTemplate>
			</ListView.Resources>

			<ListView.View>
				<GridView AllowsColumnReorder="True" ColumnHeaderToolTip="Current order">
				
					<GridViewColumn Header="" CellTemplate="{StaticResource chkBoxCell}"/>
					<GridViewColumn Header="TradeId" DisplayMemberBinding="{Binding Path=Id}" />
					<!--<GridViewColumn Header="OrderState" DisplayMemberBinding="{Binding Path=Order.State}" />
					<GridViewColumn Header="Symbol" DisplayMemberBinding="{Binding Path=Order.Symbol}"/>
					<GridViewColumn Header="Client" DisplayMemberBinding="{Binding Path=Order.Client}"/>-->
					<GridViewColumn Header="Account" DisplayMemberBinding="{Binding Path=AccountId}"/>
					<GridViewColumn Header="TradeDt">
						<GridViewColumn.DisplayMemberBinding>
							<Binding Path="TradeDt">
								<Binding.StringFormat>yyyy/MM/dd</Binding.StringFormat>
							</Binding>
						</GridViewColumn.DisplayMemberBinding>
					</GridViewColumn>
					<GridViewColumn Header="Qty" DisplayMemberBinding="{Binding Path=Qty}"/>
					<GridViewColumn Header="Price" DisplayMemberBinding="{Binding Path=Price}"/>
					<!--<GridViewColumn Header="AskPrice" DisplayMemberBinding="{Binding Path=Order.AskPrice}" />
					<GridViewColumn Header="BidPrice" DisplayMemberBinding="{Binding Path=Order.BidPrice}" />-->

				</GridView>
			</ListView.View>
		</ListView>

        
    </DockPanel>
</UserControl>
	
